#pragma once

#include <QMainWindow>
#include "HttpDownloader.h"

QT_BEGIN_NAMESPACE
namespace Ui { class MainWindow; }
QT_END_NAMESPACE

class MainWindow : public QMainWindow
{
    Q_OBJECT

public:
    MainWindow(QWidget* parent = nullptr);
    ~MainWindow();

private slots:
    void onDownloadClicked();
    void onPauseClicked();
    void onResumeClicked();
    void onCancelClicked();

    void onProgressChanged(double percentage, qint64 bytesReceived, qint64 bytesTotal);
    void onSpeedUpdated(const QString& speed);
    void onStatusChanged(const QString& status);
    void onFinished(bool success, const QString& message);
    void onErrorOccurred(const QString& error);

private:
    Ui::MainWindow* ui;
    HttpDownloader* m_downloader;

    void updateUI();
    QString formatTimeRemaining(qint64 bytesRemaining, double speed);
};